var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var ccp_menu = cc__decorator.menu;
var def_OptimizeScrollview = /* */function (_cc$Component21) {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    return _callSuper(this, _ctor, arguments);
  }
  babel_inherits(_ctor, _cc$Component21);
  return babel_createClass(_ctor, [{
    key: "onLoad",
    value: function onLoad() {
      this.node.hasEventListener("scrolling") || this.node.on("scrolling", this.monitorRemoved, this);
      this.node.hasEventListener(cc.Node.EventType.CHILD_REMOVED) || this.node.getComponent(cc.ScrollView).content.on(cc.Node.EventType.CHILD_REMOVED, this.monitorRemoved, this);
      this.node.hasEventListener(cc.Node.EventType.CHILD_REORDER) || this.node.getComponent(cc.ScrollView).content.on(cc.Node.EventType.CHILD_REORDER, this.monitorRemoved, this);
    }
  }, {
    key: "monitorRemoved",
    value: function monitorRemoved() {
      var _this65 = this;
      this.node.getComponent(cc.ScrollView).content.children.forEach(function (e) {
        e.opacity = _this65._check_collision(e) ? 255 : 0;
      });
    }
  }, {
    key: "getBoundingBoxToWorld",
    value: function getBoundingBoxToWorld(e) {
      var t = e._contentSize.width;
      var n = e._contentSize.height;
      var o = cc.rect(-e._anchorPoint.x * t, -e._anchorPoint.y * n, t, n);
      e._calculWorldMatrix();
      o.transformMat4(o, e._worldMatrix);
      return o;
    }
  }, {
    key: "_check_collision",
    value: function _check_collision(e) {
      var t = this.getBoundingBoxToWorld(this.node.getComponent(cc.ScrollView).content.parent);
      var n = this.getBoundingBoxToWorld(e);
      t.width += .5 * t.width;
      t.height += .5 * t.height;
      t.x -= .25 * t.width;
      t.y -= .25 * t.height;
      return t.intersects(n);
    }
  }]);
}(cc.Component);
def_OptimizeScrollview = cc__decorate([ccp_ccclass, ccp_menu("v-lez/OptimizeScrollview")], def_OptimizeScrollview);
exports.default = def_OptimizeScrollview;